package com.song.exception;

import com.song.result.ResponseEnum;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author Song
 * @ClassName BusinessException
 * @description: 异常类
 * @datetime 2023年 08月 01日 14:58
 * @version: 1.0
 */
@Data
@NoArgsConstructor
public class BusinessException extends Exception {

    private Integer code;
    private String message;
    private ResponseEnum responseEnum;

    public BusinessException(String message) {
        this.message = message;
    }

    public BusinessException(ResponseEnum responseEnum, String message) {
        this.code = responseEnum.getCode();
        this.message = message;
    }

    public BusinessException(Integer code, String message,Throwable throwable) {
        super(throwable);
        this.code = code;
        this.message = message;
    }



    public BusinessException(ResponseEnum responseEnum) {
        this.code=responseEnum.getCode();
        this.message = responseEnum.getMessage();
    }


    public BusinessException(ResponseEnum responseEnum,Throwable throwable) {
        super(throwable);
        this.code=responseEnum.getCode();
        this.message = responseEnum.getMessage();
    }
}
